<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	
	/**
	 * [checkaes 加解密字符串方式]
	 * @param  [type] $ostr [description]
	 * @param  string $type [description]
	 * @return [type]       [description]
	 */
	function encryption_aes($ostr,$type='encrypt'){
			if($ostr==''){
				return '';
			}
						   
			$key = 'nAS2%8#ef!cse#ds';
			$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
			$iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
			$td = mcrypt_module_open('rijndael-128', '', 'ecb', '');
			mcrypt_generic_init($td, $key, $iv);
					   
			$str = '';
					   
			switch($type){
				case 'encrypt':
					$str = base64_encode(mcrypt_generic($td, $ostr));
					break;
					   
				case 'decrypt':
					$str = mdecrypt_generic($td, base64_decode($ostr));
					break;
			}
					   
			mcrypt_generic_deinit($td);
					   
			return $str;
	}
	
	
?>